Skip to content

Conversation

@oliche
Copy link
Contributor

@oliche oliche commented Dec 31, 2025

Fixed the main bug: all of the processing has to be done in float, even if only to reconvert to int at the end of the module.

I have also improved a few things:

  • filters had mutable arguments, switched lists to tuple
  • tests were always ignored as neurodsp module doesn't exist anymore
  • epsilon value was absolute in agc, this is valid in IBL as we always work in Volts. It will now generalize as it is relative to the rms. I have also updated the IBL version with the same change
  • In the tests in debug mode, I use viewephys to compare the traces. It turns out that the edge effects in time are larger in the spike interface version than the IBL version, this is due to the filter implementation.

oliche added a commit to int-brain-lab/ibl-neuropixel that referenced this pull request Dec 31, 2025
@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Jan 2, 2026
Copy link
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @oliche!!!

Just a few minor comments

si_recording = se.read_spikeglx(local_path, stream_id="imec0.ap")
si_recording = spre.astype(si_recording, "float")
recording_ps = si.phase_shift(si_recording)
recording_hp = si.highpass_filter(recording_ps, freq_min=300, filter_order=3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
recording_hp = si.highpass_filter(recording_ps, freq_min=300, filter_order=3)
recording_hp = spre.highpass_filter(recording_ps, freq_min=300, filter_order=3)



def agc(traces, window, epsilon=1e-8):
def agc(traces, window, epsilon=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a problem here because the espilon will change for every chunk no ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote to force espilon here because it is an helper function and compute it the init of the class.
no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but this is a second order issue, we just need to stabilize the inverse of the gain.

To mitigate, I have exposed the epsilon as a parameter in the interface. It would be useful to have a BaseRecording.estimate_rms() method to fix a single epsilon for the full processing, but this is beyond the scope of this PR.

If everyone is on-board for this, I can create an issue and summarize this discussion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. We hav an get_noise_levels(recording, method="rms") that we could run in the init if rms levels are not estimated yet. But let's discuss specifics on the new issue

oliche added a commit to int-brain-lab/ibl-neuropixel that referenced this pull request Jan 12, 2026
@oliche oliche requested a review from alejoe91 January 12, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants